//密码
var password = document.querySelector('.password input')
var reg1 = /^\d{6}$/;
password.addEventListener('blur', () => {
  if (!reg1.test(event.target.value)) {
    console.log(event.target.value);
    event.target.nextElementSibling.style.display = 'block'
  } else {
    event.target.nextElementSibling.style.display = 'none'
  }
})
//邮箱
var email = document.querySelector('.email input')
var reg3 = /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/;
email.addEventListener('blur', () => {
  if (!reg3.test(event.target.value)) {
    event.target.nextElementSibling.style.display = 'block'
  } else {
    event.target.nextElementSibling.style.display = 'none'
  }
})

function fn() {
  var span = document.querySelector('#userNname')
  var ues_name = document.querySelector('.ues_name input')
  var reg = /^[\u4e00-\u9fa5]{4,10}$/
  $.ajax({
    type: "post",
    url: "http://47.94.4.201/index.php/index/index/register",
    data: {
      name: $('#userNname').val(),
      pwd: $('#password').val(),
      emails: $('#email').val()
    },
    dataType: 'json',
    success: (a) => {
      //账号
      if (span) {
        span.nextElementSibling.style.display = 'block'
        span.nextElementSibling.innerHTML = `${a.msg}`
        alert(`${a.msg}`)
        if (a.msg == '添加成功') {
          location.assign('../登陆/登陆.html')
        }
      } else {
        // span.nextElementSibling.style.display = 'none'
      }
    },
    error: (e) => {
      console.log(e);
    }
  })
}